import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../../../../components/bottom10/bottom_app_bar_10.dart';
import '../controllers/bottom10_controller.dart';

class Bottom10View extends GetView<Bottom10Controller> {
  const Bottom10View({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('圆圈圈圈菜单'),
        centerTitle: true,
      ),
      body: Stack(
        children: [
          content(),
          bottomBar(),
        ],
      ),
    );
  }

  Widget content() {
    return Container(
      alignment: Alignment.center,
      child: Obx(() {
        return Text(controller.pageIndex.value.toString(),
            style: TextStyle(color: Colors.grey[400], fontSize: 80));
      }),
    );
  }

  Widget bottomBar() {
    // final double width = MediaQuery.of(context).size.width;
    return Positioned(
      left: 0,
      right: 0,
      bottom: 0,
      child: BottomAppBar10(
        iconList: controller.iconList,
        selectedPosition: 1,
        selectedCallback: (position) => onClickBottomBar(position),
      ),
    );
  }

  void onClickBottomBar(int index) {
    debugPrint('longer   点击了 >>> $index');
    controller.onClickBottomBar(index);
  }
}
